<script>
	import {  // LXC
		client
	} from 'main.js';
	
	import {
		mapMutations
	} from 'vuex';
	import locationWatcher from '@/utils/location.js';
	import mute_ from './pages/index/mute.mp3';
	export default {
		globalData: {
				globalPlayMute: false
		},
					
		data() {
			return {
				locationWatcherId: '', //监听器id
				maximumAge: 3 * 1000 //间隔时间10s
			}
		},
		onLaunch: function() {
			locationWatcher.startLocationService(e => {
				let {
					latitude,
					longitude
				} = e.position
				// console.log(`当前位置，经度${longitude},纬度${latitude}`)
				if (!this.locationWatcherId) {
					this.locationWatcherId = e.locationWatcherId //举例保存到data，实际可以缓存到全局 
				}
				if (getApp().globalData.globalPlayMute==false) { // 全局变量清零时，播放静音文件
					const backgroundAudioManager = uni.getBackgroundAudioManager();
					backgroundAudioManager.title = '静音';
					backgroundAudioManager.epname = ' ';
					backgroundAudioManager.src = mute_;
					this.currentAudioContext = backgroundAudioManager;
													
					//backgroundAudioManager.play(); //播放音频
				}
				
			}, (e) => {
				console.log(e, '定位失败')
			}, this.maximumAge)
		},
		onShow: function() {
			console.log('App Show')		
		},
		onHide: function() {
			console.log('App Hide')	
		},
		methods: {
			...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin']),
		}
	}
</script>

<style lang="scss">
	@import '@/uni_modules/uni-scss/index.scss';
	/* #ifndef APP-PLUS-NVUE */
	/* uni.css - 通用组件、模板样式库，可以当作一套ui库应用 */
	@import './common/uni.css';
	@import '@/static/customicons.css';

	/* H5 兼容 pc 所需 */
	/* #ifdef H5 */
	@media screen and (min-width: 768px) {
		body {
			overflow-y: scroll;
		}
	}

	uni-page-body {
		background-color: #F5F5F5 !important;
		min-height: 100% !important;
		height: auto !important;
	}

	.uni-top-window uni-tabbar .uni-tabbar {
		background-color: #fff !important;
	}

	.uni-app--showleftwindow .hideOnPc {
		display: none !important;
	}

	/* #endif */

	/* 以下样式用于 hello uni-app 演示所需 */
	page {
		background-color: #efeff4;
		height: 100%;
		font-size: 28rpx;
		/* line-height: 1.8; */
	}

	.fix-pc-padding {
		padding: 0 50px;
	}

	.uni-header-logo {
		padding: 30rpx;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 10rpx;
	}

	.uni-header-image {
		width: 100px;
		height: 100px;
	}

	.uni-hello-text {
		color: #7A7E83;
	}

	.uni-hello-addfile {
		text-align: center;
		line-height: 300rpx;
		background: #FFF;
		padding: 50rpx;
		margin-top: 10px;
		font-size: 38rpx;
		color: #808080;
	}

	/* #endif*/
</style>